package com.pinc.poop;

import java.io.File;

import android.content.Intent;
import android.text.format.Time;

public abstract class PwdProtectWidgetActivity extends PwdBaseWidgetActivity {
	@Override
	protected void onResume() {
		super.onResume();

		if ( !settings.getBoolean("pwd_protect", false))
		{
			onValidResume();
			return;
		}
			
		File val_file = new File(this.getCacheDir(), validate.VALID_FILE_NAME);
		Time now = new Time();
		now.setToNow();

		if ( !val_file.exists() || (now.toMillis(true) - val_file.lastModified()>validate.val_timeout))
		{
			val_file.delete();
			Intent intent = new Intent(this, validate.class);
			startActivity(intent);
		}
		else
		{
			onValidResume();
		}
	}
	
	protected abstract void onValidResume();

}
